package cn.melonlib.nars.names.model.enmus;

import lombok.Getter;

import java.util.List;
import java.util.Objects;

@Getter
public enum FileType {
    IMAGE("图片"),DOCUMENT("文档"),VIDEO("视频"),AUDIO("音频"),COMPRESSED("压缩包"),BOOK("电子书"),OTHER("其它文件");
    private final String label;
    FileType(String label) {
        this.label = label;
    }

    public static List<String> documentTypes=List.of(
            "application/msword",
            "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
            "application/vnd.ms-excel",
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            "application/vnd.ms-powerpoint",
            "application/vnd.openxmlformats-officedocument.presentationml.presentation"

    );

    public static FileType transType(String contentType){
        if (contentType.startsWith("text")){
            return DOCUMENT;
        }else if(contentType.startsWith("image")){
            return IMAGE;
        }else if(documentTypes.contains(contentType)){
            return DOCUMENT;
        }else if(contentType.startsWith("audio")){
            return AUDIO;
        }else if(contentType.startsWith("video")){
            return VIDEO;
        }else if(Objects.equals("application/x-zip-compressed",contentType)){
            return COMPRESSED;
        }else{
            return OTHER;
        }
    }
}
